package com.wtf.dsp.admin.controller;

import com.wtf.dsp.admin.model.dto.LoginDTO;
import com.wtf.dsp.admin.model.vo.LoginVO;
import com.wtf.dsp.admin.service.LoginService;
import com.wtf.dsp.core.api.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ClassName: LoginController
 * Description:
 * date: 2023/7/22 8:37
 *
 * @author linhuanyou
 * @version 1.0
 */
@Api(tags = "登录管理")
@RestController
@RequestMapping("/auth")
public class LoginController {

    @Autowired
    private LoginService loginService;

    @ApiOperation(value = "登录")
    @PostMapping("/login")
    public R login(@RequestBody @Validated LoginDTO login){
        LoginVO loginVO = loginService.login(login);
        return R.ok(loginVO);
    }

    @ApiOperation(value = "登出")
    @PostMapping("/logout")
    public R logout(){
        loginService.logout();
        return R.ok();
    }
}
